#!/usr/bin/python
from __future__ import with_statement
import sys
from collections import deque

def parse_file_to_graph(thefile):
   """parse the data in the file into adjacency list (map) represent the telling graph
      and the status of the teller """
   graph = { }
   num_people = int(thefile.readline())
   for i in range(0, num_people):
      name,accuseCount = thefile.readline().split()
      name,accuseCount = name.strip(), int(accuseCount)
      accusees = []
      for a in range(0, accuseCount):
         accusees.append(thefile.readline().strip())
      graph[name] = { 'status': 'T', 'accusees': accusees } # T = truthteller, L = liar
   return graph

def walk_the_graph_and_update_status(graph):
   """walk the given graph. Using the teller's status, update the teller status"""
   queue = deque(graph)
   while queue:
      accuser = graph[queue.popleft()]
      for a in accuser['accusees']:
         accusee = graph[a]
         old_status = accusee['status']
         accusee['status'] = 'L' if accuser['status'] == 'T' else 'T'
         if old_status != accusee['status']:
            queue.append(a)
   return graph

def get_num_of_liars_and_truthtellers(graph):
   """walk through the graph to get the number of liars and truthtellers"""
   liars = truthtellers = 0
   for name in graph:
      if graph[name]['status'] == 'L':
         liars += 1
      else:
         truthtellers += 1
   return liars, truthtellers

def main():
# read the number from the file
   filename = sys.argv[1]
   with open(filename) as thefile:
      graph = parse_file_to_graph(thefile)
   walk_the_graph_and_update_status(graph)
   (liars, truthtellers) = get_num_of_liars_and_truthtellers(graph)
   #print 'liars', liars, 'truthtellers', truthtellers
   print max(liars, truthtellers), min(liars, truthtellers)
   

if __name__ == "__main__":
   main()

